﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace InscriberControlClient
{
    /// <summary>
    /// Interaction logic for Window8.xaml
    /// </summary>
    public partial class Window8 : Window
    {
        public Window8()
        {
            InitializeComponent();
            Functionality.getVedejaiList(listBox1);
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = true;
        }

        private void Image_ImageFailed(object sender, ExceptionRoutedEventArgs e)
        {

        }

        private void button2_Click(object sender, RoutedEventArgs e)
        {
            int location = listBox1.SelectedIndex;
            if (location >= 0)
            {
               if (MessageBox.Show("Ar tikrai šalinti šį vedėją?","Vedėjo šalinimas",MessageBoxButton.YesNo,MessageBoxImage.Question)==MessageBoxResult.Yes){
                Functionality.removeVedėjasByName(listBox1.Items[location].ToString());
                listBox1.Items.RemoveAt(location);
               }
            }
        }

        private void button3_Click(object sender, RoutedEventArgs e)
        {
            Functionality.insertVedėjasByName(textBox1.Text);
            listBox1.Items.Add(textBox1.Text);
            textBox1.Text = "";
        }
    }
}
